<?php 
 include_once dirname(__FILE__)."/config.php";
 class ue_concepteur_principal{
		 protected $_result;
		 protected $_cnn;
		 protected $_id;
		 protected $_code_ue;
		 protected $_id_concepteur;
		 public function get_name_table(){ return "ue_concepteur";}
		 public function get_name_id(){ return "id";}
		 public function get_name_code_ue(){ return "code_ue";}
		 public function get_name_id_concepteur(){ return "id_concepteur";}
		 public function set_id($parametre){  $this->_id=$parametre;}	
		 public function set_code_ue($parametre){  $this->_code_ue=$parametre;}	
		 public function set_id_concepteur($parametre){  $this->_id_concepteur=$parametre;}	
		 public function get_result(){ return $this->_result;}
		 public function get_id(){ return $this->_id;}
		 public function get_code_ue(){ return $this->_code_ue;}
		 public function get_id_concepteur(){ return $this->_id_concepteur;}
public function __construct(){

		 	$this->_cnn=new databaseconnect();

		 }

 public function INSERT()
{

$sql=" INSERT INTO 
 ue_concepteur(
			code_ue,
			id_concepteur)
 VALUES(
			'".$this->_code_ue."',
			'".$this->_id_concepteur."')";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function UPDATE()
{

 $sql="";
if(!empty($this->_code_ue)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
code_ue='".$this->_code_ue."'";
}
if(!empty($this->_id_concepteur)){
	if(!empty($sql)){$sql.=",";}
$sql.="		
id_concepteur='".$this->_id_concepteur."'";
}
$sql="UPDATE 
ue_concepteur SET 
 ".$sql."
								WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function DELETE(){

 $sql="DELETE FROM 
ue_concepteur 
 
									WHERE id ='".$this->_id."'";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function TRANCATE(){

 $sql="DELETE FROM 
ue_concepteur ";

$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}

 public function SELECT($constraint="",$pagination="")
{

$sql=" SELECT 
 		id,
		code_ue,
		id_concepteur
		
		
 FROM 
 ue_concepteur";
if($constraint){$sql.=" WHERE 1=1 ".$constraint;}if($pagination){$sql.=$pagination;}
echo $sql;
$this->_result=$this->_cnn->query($sql);
 if(!$this->_result){return 'erreur d\'execution de la requette';}else{return 'success';}
}
public function fetch_object(){
$row=mysql_fetch_object($this->_result);
 if($this->_result){
 if($row){
		$this->_id=$row->id;
		$this->_code_ue=$row->code_ue;
		$this->_id_concepteur=$row->id_concepteur;
	
		
	
		return $row;
		}else{
					return false;
				}

			}else{
				//echo 'Erreur d\'execution de requette de selection';	
			}
			

		}

}
?>